package luogu;

import java.util.Scanner;

public class test4 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int k=sc.nextInt();
        boolean flag=false;
        for (int i=10000;i<=30000;i++){
            if((i/100)%k==0){

                if(((i/10)%1000)%k==0){

                    if((i%1000)%k==0){
                        flag=true;
                        System.out.println(i);
                    }
                }
            }
        }
        if(flag==false){
            System.out.println(0);
        }
    }


}
